package cn.jiyun.Scheduling;

import cn.jiyun.mapper.OrderInfoMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class KillCoursePublish2Redis {
    @Autowired
    private OrderInfoMapper orderInfoMapper;


    //每天凌晨1点执行一次：0 0 23 * * ?
    //每天晚上，12点，发布秒杀课程到Redis
    @Scheduled(cron = "0 0 0/1 * * ? ")
    public void publishKillCourse2Redis() {
        try {
            orderInfoMapper.updateStatus();
            log.info("删除未付款成功");
        } catch (Exception e) {
            log.error("删除未付款失败");
            throw new RuntimeException(e);
        }
    }

}
